package com.tianyang.yukuaifu.business.main.adapter;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifu.R;
import com.tianyang.yukuaifu.business.main.bean.SettleOutput;
import com.tianyang.yukuaifu.module.roundview.RoundTextView;
import com.tianyang.yukuaifu.utils.VerifyUtil;

/**
 * Description：结算方式
 * Created by xyj on 2024/11/20
 */
public class SettleManageAdapter extends BaseQuickAdapter<SettleOutput, BaseViewHolder> {

    private int chooseIndex = -1;

    public SettleManageAdapter() {
        super(R.layout.item_settle_manage);
    }

    public void setChooseIndex(int index) {
        chooseIndex = index;
        this.notifyDataSetChanged();
    }

    public int getChooseIndex() {
        return chooseIndex;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, SettleOutput item) {
        if (item != null) {
            RoundTextView settleRtv = helper.getView(R.id.settleRtv);
            settleRtv.setText(VerifyUtil.checkString(item.getName()));
            if (helper.getLayoutPosition() == chooseIndex) {
                settleRtv.getDelegate().setBackgroundColor(ContextCompat.getColor(mContext, R.color.color_base));
                settleRtv.setTextColor(ContextCompat.getColor(mContext, R.color.white));
            } else {
                settleRtv.getDelegate().setBackgroundColor(ContextCompat.getColor(mContext, R.color.c_f8f8f8));
                settleRtv.setTextColor(ContextCompat.getColor(mContext, R.color.c_333333));
            }
        }
    }
}
